//
//  CNGameClient.h
//  chuiniu
//
//  Created by zheng ji on 14-9-21.
//  Copyright (c) 2014年 jxw. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDAsyncSocket.h"
#import "CNPlayer.h"
#import "CommandDef.h"
@protocol CNGameClientProtocol <NSObject>


@optional
//对家已经下线
-(void)vsPlayerOffline;
 //有玩家请求对战
 -(void) requestPK:(CNPlayer*)vsPlayer;
//开始摇动
-(void) startShakeDiceInMutilPlayer;
//等待对家摇定骰子
-(void) waitVSPlayerShake;

//设定对家摇定所有骰子点数
-(void) setVSPlayerAllDiceNumbers:(NSMutableArray*) arrayNumbers;

//等待对方猜测
-(void)waitVSPlayerGuess;
//开始猜测
-(void)startGuessNumber;

//增加在线玩家
-(void)addOnlinePlayerList:(NSMutableArray*)arrayPlayers;

//接受对战请求
-(void)setVSPlayer:(CNPlayer*)vsPlayer;

//对家猜测数据
-(void)setVSPlayerGuessData:(NSString*)vsPlayerId count:(int) count number:(int)number;

//设置比赛结果
-(void)setMatchResult:(int)win coins:(int)coins;
@end

@interface CNGameClient : NSObject
{
   
}
/**
 解析服务器传递来的消息
 */
-(void)parseResponseMessage:(NSString*)message;
-(void)registerPlayer:(NSString*)playerName;
-(void)connectToServer;

-(void)sendLoginCommand:(CNPlayer*) player;

/**
  发送准备好开始游戏命令
 */
-(void)sendReadyPlayCommand:(CNPlayer*)player vsPlayer:(CNPlayer*)vsPlayer;
/**
 发送获取在线玩家列表的命令
 
 */
-(void)sendOnlinePlayerCommand:(NSString*) playerId startRecordNo:(int)startRecordNo endRecordNo:(int)endRecordNo;
/**
 保存玩家名称到服务器
 */
-(void)savePlayerNameToServer:(NSString*)name playerId:(NSString*)playerId;
/**
 发送拒绝对战命令
 */
-(void)sendRejectVSCommand:(CNPlayer*)vsPlayer;
/**
 发送拒绝对战命令
 */
-(void)sendRejectVSCommand:(CNPlayer*)player vsPlayerID:(CNPlayer*)vsPlayer;
/**
 发送接收对战命令
 */
-(void)sendAcceptVSCommand:(CNPlayer*)player vsPlayerID:(CNPlayer*)vsPlayer;

/*发送摇定好的骰子点数到服务器，
 
 diceNums:多个点数之间用逗号隔开
 */
-(void)sendDiceNumbers:(CNPlayer*)player diceNumbers:(NSString*) diceNums;


/**
 金币处理
 */
-(void)sendGoldCoinCommand:(CNPlayer*)player coins:(int)coins tradeType:(GoldCoinTradeType) tradeType money:(double)money;
/**
 发送猜测的数据
 count:数量
 number:骰子点数
 */
-(void)sendGuessNumber:(CNPlayer*)player count:(int)count number:(int)number;
/**
  发送猜测超时消息
 playerID: 超时玩家
 vsPlayerID: 对家
 chipCoins: 金币
 */
-(void)sendGuessTimeOver:(NSString*)playerID vsPlayerID:(NSString*)vsPlayerID chipCoins:(int)chipCoins;

/**
 选择玩家对战
 
 **/
-(void)sendSelectPlayerCommand:(NSString*)playerID vsPlayerID:(NSString*)vsPlayerID;

/**
  开看结果
 */
-(void)sendOpenMatch:(NSString*)playerId win:(int)win vsPlayerId:(NSString*)vsPlayerId;

/**
   发送退出游戏消息
 */
-(void)sendQuitGameCommand;
//@property (nonatomic) GCDAsyncSocket* asyncSocket;
@property (nonatomic) BOOL isConnected;
@property (nonatomic) BOOL playerLogined;
//@property (nonatomic) CNPlayer* vsPlayer;//对家
@property (nonatomic,assign) id<CNGameClientProtocol> gameMainViewController;
@end
